/*
 * Copyright (C) 2014 Qloudgen Technology
*/

package com.qloudgen.csb.test;

import org.apache.log4j.PropertyConfigurator;

import com.qloudgen.csb.CSBClient;
import com.qloudgen.csb.client.KfkProducer;

public class Client { 
    public static void main(String[] args) throws Exception {
    	PropertyConfigurator.configure("conf/log4j.properties");
    	
    	try {    		
    		String topic = args[1];
    		//Connection connection = new Connection();
    		//Session session = connection.createSession();
    		//Queue queue = session.createQueue(topic, args[0]);
    		//Producer client = session.createProducer(queue, 3000, 3);
    		//connection.start();
    		
    		//CSBClient client = new CSBClient(args[0], 3000, 3);

    		KfkProducer client = new KfkProducer(args[0], -1, null);
    		
    		long t = System.currentTimeMillis();
    		int n = Integer.parseInt(args[2]);
    		String s = "";
    		for (int i = 0; i < n; i++) {
    			s = "send: " + String.valueOf(i);
    			client.send(topic, s);
    		}
    		t = n*1000/(System.currentTimeMillis() - t);
    		System.out.println("tps: " + t);
    	} catch (Exception e) {
    		e.printStackTrace();
    	}
    	
    	System.exit(0);
    }    
}

